package com.example.demo.controller;

import com.example.demo.model.TaskDO;
import com.example.demo.service.impl.QuartzManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 控制器
 *
 * @author zhongxiaojian
 * @date 2020/8/14
 **/
@RestController
@RequestMapping("task")
public class TaskController {

    @Autowired
    private QuartzManager quartzManager;

    /**
     * 新增或者修改
     *
     * @param id      任务ID
     * @param cron    执行时间表达式
     * @param keyword 关键字参数
     * @return true or false
     */
    @PostMapping("saveOrEdit")
    public void addJob(@RequestParam("id") String id,
                              @RequestParam("cron") String cron,
                              @RequestParam("keyword") String keyword) {
        TaskDO taskDO = new TaskDO();
        quartzManager.addJob(taskDO);
    }
}

